
clear all
/*
use "./Telecomm.dta"   //  16 ***
gen indicator = "SCORE" // "SCORE"/"ANSWER"
gen sector = "Telecom"
merge 1:1 cnum year indicator sector using STRI_JAPAN.dta
drop if _merge != 3
*/
/*
use "./Construction.dta"   //  16 ***
gen indicator = "SCORE" // "SCORE"/"ANSWER"
gen sector = "Construction"
merge 1:1 cnum year indicator sector using STRI_JAPAN.dta
drop if _merge != 3
*/
/*
use "./Insurance.dta"   //  16 ***
gen indicator = "SCORE" // "SCORE"/"ANSWER"
gen sector = "Insurance"
merge 1:1 cnum year indicator sector using STRI_JAPAN.dta
drop if _merge != 3
*/
/*
use "./Transport.dta"   //  16 ***
gen indicator = "SCORE" // "SCORE"/"ANSWER"
gen sector = "Air transport" // 
merge 1:1 cnum year indicator sector using STRI_JAPAN.dta
drop if _merge != 3
*/
///*
use "./Financial.dta"   //  16 ***
gen indicator = "SCORE" // "SCORE"/"ANSWER"
gen sector = "Commercial banking" // 
merge 1:1 cnum year indicator sector using STRI_JAPAN.dta
drop if _merge != 3
*/

set type double

drop if year == 2021 // because no data for exrate
drop if cnum == 200 // drop WORLD
bysort year: egen sumy=sum(y) // Country-sum by each year
gen share = y/sumy // generate share
gen lnv = ln(y)
gen lnstri = ln(value)
gen lnsh = ln(share)
gen lner = ln(exrate)
gen time = year - 2004
gen t = time
gen c = cnum
tabulate cnum, generate(c)
tabulate time, generate(t)
xtset cnum year

**********************************
*SUR
**********************************
quietly gen byte baseyear = 1 if t == 16
by c (baseyear), sort: gen lnsh1 = lnsh[1]
gsort t c

reg lner lnsh1 if baseyear == 1 // REGSUPPLY  OMEGA
estimate store sup

*REG with stri and exrate
reg lnsh i.cnum i.year lner lnstri // 
estimate store str
suest sup str
nlcom ([str_mean]_b[lnstri]/(1-[sup_mean]_b[lnsh1]*[str_mean]_b[lner]) )
nlcom (1 - [str_mean]_b[lner]/(1-[sup_mean]_b[lnsh1]*[str_mean]_b[lner]) )






